[XEND][XENAPI] Split Xend global constants out to its own file.
authorAlastair Tse <atse@xensource.com>
Thu, 5 Oct 2006 16:29:19 +0000 (17:29 +0100)
committerAlastair Tse <atse@xensource.com>
Thu, 5 Oct 2006 16:29:19 +0000 (17:29 +0100)
Signed-off-by: Alastair Tse <atse@xensource.com>
tools/python/xen/xend/XendAPIConstants.py [new file with mode: 0644]
tools/python/xen/xend/XendCheckpoint.py
tools/python/xen/xend/XendConstants.py [new file with mode: 0644]
tools/python/xen/xend/image.py
tools/python/xen/xend/server/tpmif.py

diff --git a/tools/python/xen/xend/XendAPIConstants.py b/tools/python/xen/xend/XendAPIConstants.py
new file mode 100644 (file)
index 0000000..ae86abc
--- /dev/null
@@ -0,0 +1,75 @@
+#============================================================================
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#============================================================================
+# Copyright (C) 2006 XenSource Ltd.
+#============================================================================
+
+#
+# Xen API Enums
+#
+
+XEN_API_VM_POWER_STATE = (
+    'Halted',
+    'Paused',
+    'Running',
+    'Suspended',
+    'ShuttingDown',
+    'Unknown'
+)
+
+XEN_API_VM_POWER_STATE_HALTED = 0
+XEN_API_VM_POWER_STATE_PAUSED = 1
+XEN_API_VM_POWER_STATE_RUNNING = 2
+XEN_API_VM_POWER_STATE_SUSPENDED = 3
+XEN_API_VM_POWER_STATE_SHUTTINGDOWN = 4
+XEN_API_VM_POWER_STATE_UNKNOWN = 5
+
+XEN_API_CPU_FEATURE = (
+    'FPU', 'VME', 'DE', 'PSE', 'TSC', 'MSR', 'PAE'
+    'MCE', 'CX8', 'APIC', 'SEP', 'MTRR', 'PGE', 'MCA',
+    'CMOV', 'PAT', 'PSE36', 'PN', 'CLFLSH', 'DTES',
+    'ACPI', 'MMX', 'FXCR', 'XMM', 'XMM2', 'SELFSNOOP',
+    'HT', 'ACC', 'IA64', 'SYSCALL', 'MP', 'NX', 'MMXEXT',
+    'LM', '3DNOWEXT', '3DNOW', 'RECOVERY', 'LONGRUN',
+    'LRTI', 'CXMMX', 'K6_MTRR', 'CYRIX_ARR', 'CENTAUR_MCR',
+    'K8', 'K7', 'P3', 'P4', 'CONSTANT_TSC', 'FXSAVE_LEAK',
+    'XMM3', 'MWAIT', 'DSCPL', 'EST', 'TM2', 'CID', 'CX16',
+    'XTPR', 'XSTORE', 'XSTORE_EN', 'XCRYPT', 'XCRYPT_EN',
+    'LAHF_LM', 'CMP_LEGACY'
+)
+
+XEN_API_ON_NORMAL_EXIT = (
+    'destroy',
+    'restart',
+)
+
+XEN_API_ON_CRASH_BEHAVIOUR = (
+    'destroy',
+    'coredump_and_destroy',
+    'restart',
+    'coredump_and_restart',
+    'preserve',
+    'rename_restart'
+)
+
+XEN_API_BOOT_TYPE = (
+    'bios',
+    'grub',
+    'kernel_external',
+    'kernel_internal'
+)
+
+XEN_API_VBD_MODE = ('RO', 'RW')
+
+XEN_API_DRIVER_TYPE = ('ioemu', 'paravirtualised')
index 6d36d0f1b4469496400576eefd38a8045635706e..158c6c378114a1f17386fac0c5c8cec7a31a13ca 100644 (file)
@@ -18,8 +18,7 @@ import xen.lowlevel.xc
 from xen.xend import balloon, sxp
 from xen.xend.XendError import XendError
 from xen.xend.XendLogging import log
-from xen.xend.XendDomainInfo import DEV_MIGRATE_STEP1, DEV_MIGRATE_STEP2
-from xen.xend.XendDomainInfo import DEV_MIGRATE_STEP3
+from xen.xend.XendConstants import *
 
 SIGNATURE = "LinuxGuestRecord"
 XC_SAVE = "xc_save"
diff --git a/tools/python/xen/xend/XendConstants.py b/tools/python/xen/xend/XendConstants.py
new file mode 100644 (file)
index 0000000..d956c2f
--- /dev/null
@@ -0,0 +1,96 @@
+#============================================================================
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#============================================================================
+# Copyright (C) 2006 XenSource Ltd.
+#============================================================================
+
+from xen.xend.XendAPIConstants import *
+
+#
+# Shutdown codes and reasons.
+#
+
+DOMAIN_POWEROFF = 0 
+DOMAIN_REBOOT   = 1
+DOMAIN_SUSPEND  = 2
+DOMAIN_CRASH    = 3
+DOMAIN_HALT     = 4
+
+DOMAIN_SHUTDOWN_REASONS = {
+    DOMAIN_POWEROFF: "poweroff",
+    DOMAIN_REBOOT  : "reboot",
+    DOMAIN_SUSPEND : "suspend",
+    DOMAIN_CRASH   : "crash",
+    DOMAIN_HALT    : "halt"
+}
+
+restart_modes = [
+    "restart",
+    "destroy",
+    "preserve",
+    "rename-restart"
+    ]
+
+DOM_STATES = [
+    'halted',
+    'paused',
+    'running',
+    'suspended',
+    'shutdown',
+    'unknown',
+]
+
+DOM_STATE_HALTED = XEN_API_VM_POWER_STATE_HALTED
+DOM_STATE_PAUSED = XEN_API_VM_POWER_STATE_PAUSED
+DOM_STATE_RUNNING = XEN_API_VM_POWER_STATE_RUNNING
+DOM_STATE_SUSPENDED = XEN_API_VM_POWER_STATE_SUSPENDED
+DOM_STATE_SHUTDOWN = XEN_API_VM_POWER_STATE_SHUTTINGDOWN
+DOM_STATE_UNKNOWN = XEN_API_VM_POWER_STATE_UNKNOWN
+
+DOM_STATES_OLD = [
+    'running',
+    'blocked',
+    'paused',
+    'shutdown',
+    'crashed',
+    'dying'
+    ]
+
+STATE_DOM_OK       = 1
+STATE_DOM_SHUTDOWN = 2
+
+SHUTDOWN_TIMEOUT = 30.0
+
+ZOMBIE_PREFIX = 'Zombie-'
+
+"""Minimum time between domain restarts in seconds."""
+MINIMUM_RESTART_TIME = 20
+
+RESTART_IN_PROGRESS = 'xend/restart_in_progress'
+
+#
+# Device migration stages (eg. XendDomainInfo, XendCheckpoint, server.tpmif)
+#
+
+DEV_MIGRATE_TEST  = 0
+DEV_MIGRATE_STEP1 = 1
+DEV_MIGRATE_STEP2 = 2
+DEV_MIGRATE_STEP3 = 3
+
+#
+# Xenstore Constants
+#
+
+XS_VMROOT = "/vm/"
+
index ee31c33437bed2b586094780724aaa0708845f27..4abb8f3f0024fb2740e122f306e44e0579ec49a0 100644 (file)
@@ -412,7 +412,7 @@ class HVMImageHandler(ImageHandler):
         """ watch call back on node control/shutdown,
             if node changed, this function will be called
         """
-        from xen.xend.XendDomainInfo import shutdown_reasons
+        from xen.xend.XendConstants import DOMAIN_SHUTDOWN_REASONS
         xd = xen.xend.XendDomain.instance()
         vm = xd.domain_lookup( self.vm.getDomid() )
 
index 71ec6e15cb0bf7883f6bef8ea30d8c2e5047fb09..6f6ab93b1a92f59cbb0e3be48fb47c571035f504 100644 (file)
 """
 
 from xen.xend import sxp
+from xen.xend import XendRoot
 from xen.xend.XendLogging import log
 from xen.xend.XendError import XendError
-from xen.xend import XendRoot
-from xen.xend.XendDomainInfo import DEV_MIGRATE_TEST
-
+from xen.xend.XendConstants import DEV_MIGRATE_TEST
 from xen.xend.server.DevController import DevController
 
 import os
 import re
 
-
 xroot = XendRoot.instance()
 
-
 class TPMifController(DevController):
     """TPM interface controller. Handles all TPM devices for a domain.
     """